//
//  SignMianBGView.m
//  Safflower
//
//  Created by 袁亮 on 2016/12/27.
//  Copyright © 2016年 Migic_Z. All rights reserved.
//

#import "SignMianBGView.h"

@interface SignMianBGView()<UICollectionViewDataSource, UICollectionViewDelegate>
{
    CGFloat _selfWidth;
    CGFloat _selfHeight;
}
@property (nonatomic, strong) UICollectionView *bg_collection_view;

@end

@implementation SignMianBGView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        _selfWidth = SCREEN_WIDTH - 60;
        _selfHeight = SCREEN_HEIGHT - 100;
        
        [self makeSignMainBGView];
    }
    return self;
}

- (void)makeSignMainBGView
{
    CGFloat leftWidth = _selfWidth - (_selfWidth) / 3;
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.minimumLineSpacing = 1;
    flowLayout.minimumInteritemSpacing = 1;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.itemSize = CGSizeMake((leftWidth - 7) / 8, (_selfHeight - 3) / 4);
    
    _bg_collection_view = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    _bg_collection_view.dataSource = self;
    _bg_collection_view.delegate = self;
    [_bg_collection_view registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"BGCell"];
    _bg_collection_view.backgroundColor = RGB(220, 220, 220);
    [self addSubview:_bg_collection_view];
    [_bg_collection_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];

}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 32;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *bgCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BGCell" forIndexPath:indexPath];
    
    bgCell.backgroundColor = [UIColor whiteColor];
    return bgCell;
}

@end
